<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="团队名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入团队名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="指导单位" prop="college">
        <el-select v-model="queryParams.college" placeholder="请选择" clearable size="small">
          <el-option
            v-for="(dict, index) in unitNameList"
            :key="index"
            :label="dict.sponsorName"
            :value="dict.sponsorName"
          />
        </el-select>
        <!-- <el-input
          v-model="queryParams.college"
          placeholder="请输入指导单位"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        /> -->
      </el-form-item>
      <el-form-item label="调研主题" prop="researchtopic">
        <el-select
          v-model="queryParams.researchtopic"
          placeholder="调研主题"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in researchtopics"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="推荐项" prop="researchtopic">
        <el-select
          v-model="queryParams.researchtopic"
          placeholder="推荐项"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in recommendOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item> -->

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <span style="font-weight: bold">校园大赛</span>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="applySchoolMatch = true"
          v-hasPermi="['eqxm:schoolmatchRecommend:apply']"
          >申请校赛</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="inCollegeScoreOpen"
          v-hasPermi="['eqxm:schoolmatchRecommend:inScore']"
          >录入系部成绩</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          style="padding: 8px"
          type="danger"
          size="mini"
          v-hasPermi="['eqxm:schoolmatch:remove']"
          @click="handleDelete"
        >
          取消参赛
        </el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button type="primary" plain size="mini" @click="recommendSchoolMatch" v-hasPermi="['eqxm:schoolmatchRecommend:recommend']"
          >推荐团队</el-button
        >
      </el-col> -->

      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table border v-loading="loading" :data="teamList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column label="团队名称" align="center" prop="name" />
      <el-table-column label="负责人" align="center">
        <template slot-scope="scope">
          <div
            style="border-bottom: 1px solid #ddd"
            v-for="(val, index) in scope.row.eqxmTeamStudentList"
            :key="index"
            v-show="val.role == '1'"
          >
            <div>{{ val.name }}-{{ val.username + '\n' }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="指导单位" align="center" prop="college" />
      <el-table-column
        label="调研主题"
        :formatter="researchtopicFormat"
        align="center"
        prop="researchtopic"
      />
      <el-table-column label="实打/应打" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <span>{{ scope.row.clockCount }}/{{ scope.row.studentCount }}</span>
          <br />
          <span>{{ GetPercent(scope.row.clockCount, scope.row.studentCount) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="系部评分" align="center" prop="collegeScore1" />

      <el-table-column label="系部排名" align="center" prop="rank">
        <template slot-scope="scope">
          <span>{{ scope.row.rank }}/{{ scope.row.rankCount }}</span>
        </template>
      </el-table-column>
      <el-table-column label="团队材料" align="center" prop="college">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-document" @click="teamDetail(scope.row)"
            >团队信息</el-button
          >
          <!-- v-hasPermi="['eqxm:schoolmatchScore:teamDetail']" -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-document"
            @click="seeUpload(scope.row, '3')"
            >宣传材料</el-button
          >
          <!-- v-hasPermi="['eqxm:schoolmatchScore:sumDetail']" -->
        </template>
      </el-table-column>
      <el-table-column label="总结材料" align="center" prop="college">
        <template slot-scope="scope">
          <el-button
            v-show="scope.row.schoolMatchStatus1 != 1"
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="openUrl(scope.row.id)"
            v-hasPermi="['eqxm:schoolmatchScore:sumDetail']"
            >材料</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="schoolMatchStatus1" width="150">
        <template slot-scope="scope">
          <!-- {{ dict.type.schoolmatch_1.get(scope.row.schoolMatchStatus1) }} -->
          <el-tooltip
            v-if="scope.row.schoolMatchStatus1 == 1 && scope.row.examineComments1"
            class="item"
            effect="dark"
            placement="top"
          >
            <div slot="content">
              {{ scope.row.examineComments1 }}
            </div>
            <i class="el-icon-warning-outline" style="color: #e6a23c"></i>
          </el-tooltip>
          <dict-tag
            :options="dict.type.schoolmatch_1"
            :value="scope.row.schoolMatchStatus1"
            style="display: inline-block; margin-left: 8px"
          />
          <br />
          <a
            style="color: #409eff; text-decoration: underline"
            class="tag-read"
            v-if="scope.row.schoolMatchStatus1 == 2 || scope.row.schoolMatchStatus1 == 0"
            :data-clipboard-text="'https://erke.hdu.edu.cn/weixin/#/pages/index/practice/checkPractice?id=' + scope.row.id +'&type=1'"
            @click="copy"
          >
            复制审核链接
          </a>
        </template>
      </el-table-column>

      <el-table-column label="总分" align="center" prop="totalScore1">
        <template slot-scope="scope">
          <p v-if="scope.row.clockScore && scope.row.onlineScore1 && scope.row.offlineScore">
            {{ scope.row.totalScore1 }}
          </p>
        </template>
      </el-table-column>
      <el-table-column label="获得奖项" align="center" prop="advancedPrize" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            v-hasPermi="['eqxm:schoolmatchRecommend:upload']"
            v-show="scope.row.schoolMatchStatus1 == 1 || scope.row.schoolMatchStatus1 == 2"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            >上传材料</el-button
          >
          <el-button
            v-hasPermi="['eqxm:schoolmatchRecommend:examine']"
            v-show="scope.row.schoolMatchStatus1 == 2"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="examineOpenF(scope.row)"
            >审核</el-button
          >
          <el-button
            v-hasPermi="['eqxm:schoolmatchRecommend:recommend']"
            v-show="scope.row.schoolMatchStatus1 == 0"
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="examineOpenF2(scope.row)"
            >副书记审核</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改团队对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="名称" prop="name">
          <el-input v-model="form.name" placeholder="请输入名称" />
        </el-form-item>
        <el-form-item label="系部" prop="college">
          <el-input v-model="form.college" placeholder="请输入系部" />
        </el-form-item>
        <el-form-item label="调研主题" prop="researchtopic">
          <el-input v-model="form.researchtopic" placeholder="请输入调研主题" />
        </el-form-item>
        <el-form-item label="是否重点" prop="isimportant">
          <el-input v-model="form.isimportant" placeholder="请输入是否重点" />
        </el-form-item>
        <el-form-item label="呈现形式" prop="presentation">
          <el-input v-model="form.presentation" placeholder="请输入呈现形式" />
        </el-form-item>
        <el-form-item label="呈现形式详情" prop="presentationdetail">
          <el-input v-model="form.presentationdetail" placeholder="请输入呈现形式详情" />
        </el-form-item>
        <el-form-item label="交通费" prop="transportation">
          <el-input v-model="form.transportation" placeholder="请输入交通费" />
        </el-form-item>
        <el-form-item label="住宿费" prop="accommodation">
          <el-input v-model="form.accommodation" placeholder="请输入住宿费" />
        </el-form-item>
        <el-form-item label="宣传费" prop="publicity">
          <el-input v-model="form.publicity" placeholder="请输入宣传费" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog title="录入系部成绩" :visible.sync="psOpen" width="500px" append-to-body>
      <el-table border :data="psList" @selection-change="handleSelectionChange">
        <el-table-column label="团队名称" align="center" prop="name" />
        <el-table-column label="分数" align="center" prop="collegeScore1">
          <template slot-scope="scope">
            <el-input v-model.number="scope.row.collegeScore1"></el-input>
          </template>
        </el-table-column>
      </el-table>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="psSubmitForm">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="上传材料" :visible.sync="upload.open" width="400px" append-to-body>
      <el-upload
        ref="upload"
        :limit="2"
        :action="upload.url"
        :file-list="upload.fileList"
        :on-progress="handleFileUploadProgress"
        :on-error="handleUploadError"
        :on-exceed="handleExceed"
        :on-remove="handleFileRemove"
        :before-remove="beforeRemove"
        :on-change="fileChange"
        :headers="upload.headers"
      >
        <!-- :disabled="upload.isUploading"  -->
        <el-button size="small" type="primary">材料上传</el-button>
        <div slot="tip" class="el-upload__tip">
          请上传图文材料和视频材料各一个,限两个文件,大小不能超过1GB
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 审核对话框 -->
    <el-dialog :title="title" :visible.sync="examineOpen" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="审核意见" prop="examineComments1">
          <el-input v-model="examineComments1" placeholder="请输入审核意见" />
        </el-form-item>
        <el-button type="primary" @click="submitFormE('1')">审核拒绝</el-button>
        <el-button type="primary" @click="submitFormE('0')">审核通过</el-button>
      </el-form>
      <!--      <div slot="footer" class="dialog-footer">
	        <el-button type="primary" @click="submitForm">确 定</el-button>
	      </div> -->
    </el-dialog>

    <!-- 二级审核对话框 -->
    <el-dialog :title="title" :visible.sync="examineOpen2" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="审核意见" prop="examineComments1">
          <el-input v-model="examineComments1" placeholder="请输入审核意见" />
        </el-form-item>
        <el-button type="primary" @click="submitFormE('1')">审核拒绝</el-button>
        <el-button type="primary" @click="submitFormE('3')">审核通过</el-button>
      </el-form>
    </el-dialog>
    <!-- 文件列表对话框 -->
    <el-dialog title="总结材料" :visible.sync="collegeOpen" width="500px" append-to-body>
      <el-table :data="collegeTableData" style="width: 100%">
        <el-table-column prop="name" label="文件名" width="180"> </el-table-column>
        <!-- <el-table-column prop="url" label="路径" width="180"> </el-table-column> -->
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="downLoadFile(scope.row.url)"
              >下载</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <!-- 申请校赛对话框 -->
    <el-dialog title="申请校赛" :visible.sync="applySchoolMatch" width="350px" append-to-body>
      <el-select
        v-model="applyTeam"
        placeholder="实践团队"
        clearable
        size="small"
        style="width: 240px"
      >
        <el-option v-for="dict in teamOptions" :key="dict.id" :label="dict.name" :value="dict.id" />
      </el-select>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitSchoolMatch('1')">确 定</el-button>
        <el-button @click="applySchoolMatch = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listTeam,
  getTeam,
  delTeam,
  addTeam,
  updateTeam,
  exportTeam,
  getHaveReviewRole,
  recommendSchoolMatch,
  listPs,
  psSubmitForm,
  SchoolMatchUpload,
  downloadTemplateTeam,
  removeSchoolmatch1,
  collegeDownload,
} from '@/api/eqxm/team';
import { listSponsor } from "@/api/system/sponsor";
import { getUserTeam } from '@/api/eqxm/teamStudent';
import CommonUtils from '@/utils/CommonUtils';
import { getToken } from '@/utils/auth';
import Clipboard from 'clipboard';
export default {
  name: 'Team',
  dicts: ['schoolmatch_1'],
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 团队表格数据
      teamList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        params: {
          schoolSearch: '1',
        },
        name: null,
        college: null,
        researchtopic: null,
        isimportant: null,
        presentation: null,
        presentationdetail: null,
        transportation: null,
        accommodation: null,
        publicity: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      recommendOptions: [],
      isHaveReviewRole: false,
      schoolMatchStatuss: [],
      researchtopics: [],
      psOpen: false,
      psList: [],
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: '',
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: 'Bearer ' + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + '/common/upload',
        // url: process.env.VUE_APP_BASE_API + '/system/user/importData',
        college: '',
        fileChangeFlag: false,
        fileList: [],
        teamid: '',
        progressFlag: true, // 显示进度条
        loadProgress: 0,
      },
      examineOpen: false,
      examineOpen2: false,
      collegeOpen: false,
      examineComments1: '',
      //校赛弹框
      applySchoolMatch: false,
      teamOptions: [],
      applyTeam: null,
      unitNameList: [],

      subUpFilelist: [],
      collegeTableData: {},
    };
  },
  created() {
    this.getHaveReviewRole();
    this.getDicts('teamstatus').then(response => {
      this.teamstatus = response.data;
    });
    this.getDicts('researchtopic').then(response => {
      this.researchtopics = response.data;
    });
    this.getDicts('isimportant').then(response => {
      this.isimportants = response.data;
    });
    this.getDicts('schoolMatchStatus1').then(response => {
      this.schoolMatchStatuss = response.data;
    });
    listSponsor().then(response => {
      this.unitNameList = response.rows;
      console.log(response, '111');
    });
    this.getList();
    this.getDicts('recommend').then(response => {
      this.recommendOptions = response.data;
    });
    getUserTeam().then(response => {
      this.teamOptions = response.data;
      //   if(this.teamOptions.length>0){
      // 	  this.upload.college=this.teamOptions[0].college;

      //   }
    });
  },
  methods: {
    // 判断多选是否禁用
    selectable(row, index) {
      console.log(row, index, 'select');
      if (this.teamList[index].schoolMatchStatus1 == 0) {
        return true;
      } else {
        return false;
      }
    },
    statusFormat(row, column) {
      return this.selectDictLabel(this.teamstatus, row.status);
    },
    isimportantFormat(row, column) {
      return this.selectDictLabel(this.isimportants, row.isimportant);
    },
    researchtopicFormat(row, column) {
      return this.selectDictLabel(this.researchtopics, row.researchtopic);
    },
    recommendFormat(row, column) {
      return this.selectDictLabel(this.recommendOptions, row.recommend);
    },
    schoolMatchStatusFormat(row, column) {
      return this.selectDictLabel(this.schoolMatchStatuss, row.schoolMatchStatus1);
    },
    /** 查询团队列表 */
    getList() {
      this.loading = true;
      console.log(this.queryParams, 'this.queryParams');
      listTeam(this.queryParams).then(response => {
        this.teamList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        delFlag: null,
        college: null,
        createBy: null,
        researchtopic: null,
        isimportant: null,
        createTime: null,
        presentation: null,
        updateBy: null,
        presentationdetail: null,
        updateTime: null,
        transportation: null,
        accommodation: null,
        publicity: null,
      };
      this.resetForm('form');
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm');
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      //清空store的项目信息
      let teamInfo = {
        id: '',
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/team/teamManage', //跳转的路径
        query: { type: 0 },
      });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      /* this.reset();
      let teamInfo = {
        id:row.id
      }
      CommonUtils.setCurTeamInfo(teamInfo)
      const vm = this
      vm.$router.push({  //核心语句
        path:'/team/teamManage',//跳转的路径
        query: {type:0}
      }) */
      this.subUpFilelist = [];
      this.upload.fileList = [];
      this.upload.id = row.id;
      this.upload.title = '申请先进个人';
      this.upload.open = true;
    },
    copy() {
      var clipboard = new Clipboard('.tag-read');
      clipboard.on('success', e => {
        console.log('复制成功');
        this.$modal.msgSuccess('复制成功');
        // 释放内存
        clipboard.destroy();
      });
      clipboard.on('error', e => {
        // 不支持复制
        console.log('该浏览器不支持自动复制');
        this.$modal.msgError('该浏览器不支持自动复制');
        // 释放内存
        clipboard.destroy();
      });
    },
    upload(row) {
      this.reset();
      let teamInfo = {
        id: row.id,
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/team/upload', //跳转的路径
        query: { type: 0 },
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs['form'].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateTeam(this.form).then(response => {
              this.$modal.msgSuccess('修改成功');
              this.open = false;
              this.getList();
            });
          } else {
            addTeam(this.form).then(response => {
              this.$modal.msgSuccess('新增成功');
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete() {
      const ids = this.ids;
      console.log(ids, 'ids');
      if (ids.length > 0) {
        this.$confirm('是否确认批量移除校赛！', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(function () {
            return removeSchoolmatch1(ids);
          })
          .then(() => {
            this.getList();
            this.$modal.msgSuccess('删除成功');
          });
      } else {
        this.$modal.msgError('请选择团队！');
      }
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有团队数据项?', '警告', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(function () {
          return exportTeam(queryParams);
        })
        .then(response => {
          this.download(response.msg);
        });
    },
    /** 团队信息按钮 */
    teamDetail(row) {
      this.reset();
      let teamInfo = {
        id: row.id,
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatchRecommend/teamManage', //跳转的路径
        query: { type: 0 },
      });
    },
    // 下载
    openUrl(id) {
      // var params = {
      //   id: id,
      //   schoolMatchType: 1,
      // };
      // this.collegeOpen = true;
      // collegeDownload(params).then(response => {
      //   this.collegeTableData = response.data;
      // });
      window.open(
        process.env.VUE_APP_BASE_API +`/eqxm/team/SchoolMatchUpload/download?id=${id}&schoolMatchType=1`
      );
    },
    downLoadFile(url) {
      window.open(process.env.VUE_APP_BASE_API + url);
    },
    seeUpload(row, uploadId) {
      // debugger
      let teamInfo = {
        id: row.id,
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatchRecommend/seeUpload/' + uploadId, //跳转的路径
      });
    },
    recommendTeam() {
      let teamInfo = {
        id: '',
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatch/recommendTeam', //跳转的路径
      });
    },
    judge() {
      let teamInfo = {
        id: '',
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatch/judge', //跳转的路径
      });
    },
    review() {
      let teamInfo = {
        id: '',
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatch/review', //跳转的路径
      });
    },
    collegeScore1() {
      let teamInfo = {
        id: '',
      };
      CommonUtils.setCurTeamInfo(teamInfo);
      const vm = this;
      vm.$router.push({
        //核心语句
        path: '/schoolmatch/collegeScore1', //跳转的路径
      });
    },
    getHaveReviewRole() {
      getHaveReviewRole().then(response => {
        this.isHaveReviewRole = response;
      });
    },
    GetPercent(num, total) {
      num = parseFloat(num);
      total = parseFloat(total);
      if (isNaN(num) || isNaN(total)) {
        return '=';
      }
      return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0 + '%';
    },
    recommendSchoolMatch(itemId) {
      // const userIds = itemId || this.ids;
      // if (userIds.length == 0) {
      //   this.$modal.msgError('请选择');
      //   return;
      // }
      // recommendSchoolMatch(userIds).then(response => {
      //   this.$modal.msgSuccess('推荐成功');
      //   this.getList();
      //   this.open = false;
      // });
    },
    inCollegeScoreOpen() {
      listPs(1).then(response => {
        this.psList = response.data;
        this.loading = false;
        this.psOpen = true;
      });
    },
    psSubmitForm() {
      psSubmitForm(this.psList, 1).then(response => {
        this.$modal.msgSuccess('打分成功');
        this.getList();
        this.psOpen = false;
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    /** 文件移除时 */
    handleFileRemove(file, fileList) {
      // this.upload.fileList = [];
      // this.upload.fileList.splice(index, 1);
      this.subUpFilelist = [];
      for (let i = 0; i < fileList.length; i++) {
        if (fileList[i].response) {
          this.subUpFilelist.push({
            name: fileList[i].response.originalFilename,
            url: fileList[i].response.fileName,
          });
        }
      }
      console.log(this.subUpFilelist, 'fileList[{}]');
      this.form.rcgcDocumentFileType = '';
    },
    // 文件改变时
    fileChange(file, fileList) {
      this.upload.fileChangeFlag = true;
      this.upload.fileList = fileList;
      console.log(fileList[0].response ? fileList[0].response.originalFilename : '', 'fileList[]]');
      this.subUpFilelist = [];
      for (let i = 0; i < fileList.length; i++) {
        if (fileList[i].response) {
          this.subUpFilelist.push({
            name: fileList[i].response.originalFilename,
            url: fileList[i].response.fileName,
          });
        }
      }
      console.log(this.subUpFilelist, 'fileList[]]');
      console.log(fileList.length, 'fileList');
      //文件改变回填选中文件的类型
      // let fileName = file.name;
      // let type = fileName.split('.')[fileName.split('.').length - 1];

      // this.form.rcgcDocumentFileType = type;
    },
    // 文件移除之前
    beforeRemove(file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
    // 文件个数超出
    handleExceed() {
      this.$message.error(`只允许上传两个文件，请先删除已上传的文件！`);
    },
    // 上传失败
    handleUploadError(err) {
      this.$message.error('上传失败, 请重试');
    },
    // 获取文件名称
    getFileName(name) {
      if (name.lastIndexOf('/') > -1) {
        return name.slice(name.lastIndexOf('/') + 1).toLowerCase();
      } else {
        return '';
      }
    },
    /** 提交按钮 */
    submitFileForm() {
      if (this.upload.fileList == null || this.upload.fileList.length <= 0) {
        this.$modal.msgError('请上传文件模板');
        return;
      }
      let fileSize = this.upload.fileList[0].size / (1024 * 1024);
      if (fileSize > 1024) {
        this.$modal.msgError('上传文件过大，请重新选择文件上传');
        return false;
      }
      var testmsg = this.upload.fileList[0].name.substring(
        this.upload.fileList[0].name.lastIndexOf('.') + 1
      );
      // const extension = testmsg === 'xls';
      // const extension2 = testmsg === 'xlsx';
      // const extension3 = testmsg === 'doc';
      // const extension4 = testmsg === 'docx';
      // const extension5 = testmsg === 'txt';
      // // const isLt2M = file.size / 1024 / 1024 < 10
      // if (!extension && !extension2 && !extension3 && !extension4 && !extension5) {
      //   this.$message({
      //     message: '只能上传doc、docx、xls、xlsx格式的文件!',
      //     type: 'warning',
      //   });
      //   return false;
      // }

      // let formData = new FormData();
      // // this.upload.fileList.forEach(file => {
      // //   formData.append('file', file.raw);
      // // });
      // formData.append('file', this.subUpFilelist);
      // formData.append('college', this.upload.college);
      // formData.append('id', this.upload.id);
      // formData.append('schoolMatchType', 1);
      var formData = {
        files: this.subUpFilelist,
        id: this.upload.id,
        schoolMatchType: 1,
      };
      SchoolMatchUpload(formData).then(response => {
        this.$modal.msgSuccess('申请成功');
        this.upload.open = false;
        this.getList();
      });
    },
    /** 下载按钮操作 */
    teamHandleDownload(row) {
      this.reset();
      const id = row.id || this.ids;
      downloadTemplateTeam(id).then(response => {
        if (response != undefined || response != null) {
          if (response.data.size > 0) {
            let fileName = decodeURI(response.headers.contentfile);

            let contentType = 'application/x-msdownload;';
            let blob = new Blob([response.data], {
              type: contentType + 'charset=UTF-8',
            });
            if (window.navigator.msSaveOrOpenBlob) {
              //IE10+下载
              navigator.msSaveBlob(blob, fileName);
            } else {
              // 非IE下载
              var link = document.createElement('a');
              link.href = window.URL.createObjectURL(blob);
              link.download = fileName;
              link.click();
              //释放内存
              window.URL.revokeObjectURL(link.href);
            }
          }
        }
      });
    },
    // 申请校赛
    submitSchoolMatch(res) {
      let subForm = {};
      subForm.schoolMatchStatus1 = res;
      subForm.id = this.applyTeam;
      updateTeam(subForm).then(response => {
        if (response.code == 200) {
          this.$modal.msgSuccess('申请成功');
          this.getList();
          this.applySchoolMatch = false;
        }
      });
    },
    examineOpenF(row) {
      this.title = row.name + ' 审核';
      this.form = row;
      this.form.creditExamineComments = '';
      this.teamid = row.id;
      this.examineOpen = true;
    },
    examineOpenF2(row) {
      this.title = row.name + ' 副书记审核';
      this.form = row;
      this.form.creditExamineComments = '';
      this.teamid = row.id;
      this.examineOpen2 = true;
    },
    // 审核
    submitFormE(res) {
      if (res != '1' || this.examineComments1) {
        let subForm = {};
        subForm.schoolMatchStatus1 = res;
        subForm.examineComments1 = this.examineComments1;
        subForm.id = this.teamid;
        if (res == 3) {
          subForm.onlineStatus1 = 0;
        }
        updateTeam(subForm).then(response => {
          if (response.code == 200) {
            this.$modal.msgSuccess('审核成功');
            this.getList();
            this.examineOpen = false;
            this.examineOpen2 = false;
          }
        });
      } else {
        this.$modal.msgError('审核拒绝请填写理由！');
      }
    },
  },
};
</script>
